CentOS 7
Sponsored Link

Ruby on Rails 4
2016/07/03
 
Install Ruby on Rails 4 to build Ruby Framework environment.
[1]
[2] Install some other required packages.
# install from EPEL, SCLo

[root@dlp ~]#
yum --enablerepo=epel,centos-sclo-rh -y install rh-ruby22-ruby-devel nodejs libuv gcc make libxml2 libxml2-devel mariadb-devel zlib-devel libxslt-devel
[3] Install Rails 4.
[root@dlp ~]#
gem install bundler

[root@dlp ~]#
gem install nokogiri -- --use-system-libraries

[root@dlp ~]#
gem install rails --version="~>4.0" --no-ri --no-rdoc

[root@dlp ~]#
rails -v

Rails 4.2.6
[4] Create a sample application and make sure it works normally.
Install MariaDB Server first, refer to here.
[root@dlp ~]#
gem install mysql2 --no-ri --no-rdoc -- --with-mysql-config=/usr/bin/mysql_config

[root@dlp ~]#
rails new SampleApp -d mysql

[root@dlp ~]#
cd SampleApp

[root@dlp SampleApp]#
vi config/database.yml
default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: root
  password:
password
 
# MariaDB password

  socket: /var/lib/mysql/mysql.sock
# create test application

[root@dlp SampleApp]#
rake db:create

[root@dlp SampleApp]#
rails generate scaffold testapp name:string title:string body:text

[root@dlp SampleApp]#
rake db:migrate

[root@dlp SampleApp]#
rails server --binding=0.0.0.0

=> Booting WEBrick
=> Rails 4.2.6 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-07-03 19:07:29] INFO  WEBrick 1.3.1
[2016-07-03 19:07:29] INFO  ruby 2.2.2 (2015-04-13) [x86_64-linux]
[2016-07-03 19:07:29] INFO  WEBrick::HTTPServer#start: pid=3225 port=3000
[5] Access to the "http://(server's hostname or IP address):3000/" from a client computer. It's OK if following site is displayed normally.
  Access to "http://(server's hostname or IP address):3000/testapps/", then it's possbile to use sample app like follows.
 
Tweet